import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import './assets/styles/common.styl'
import 'normalize.css'
import Scroll from './lib/scroll'
import $API from '@/api/services'
Vue.prototype.$API = $API
import $CONFIG from '@/config'
Vue.prototype.$CONFIG = $CONFIG

import $AUTH from '@/utils/auth'//接口
Vue.prototype.$AUTH = $AUTH

import krp from '@/plugins'
Vue.use(krp)

// import utils from '@/plugins/utils'
// Vue.prototype.$utils = utils

import vgo from '@/plugins/bus'
Vue.use(vgo)

import RegionPicker from 'vue-region-picker'
import CHINA_REGION from 'china-area-data'

Vue.use(RegionPicker, {
  region: CHINA_REGION,
  vueVersion: 2
})

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

import Vant from 'vant'
import 'vant/lib/index.css'
import '@vant/touch-emulator'
Vue.use(Vant);
// import 'vant/lib/vant-css/index.css'

import VueAMap from 'vue-amap'
Vue.use(VueAMap)
VueAMap.initAMapApiLoader({
  key: 'b65d581a9e00d6952661f5e0056e3649', // production
  plugin: ['AMap.CitySearch', 'AMap.Geolocation', 'AMap.Geocoder'],
  v: '1.4.4'
})

// 日志插件
import './utils/log'
import { Toast } from 'vant'
Vue.use(Toast);
import './permission.js'

Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$_router = router


// 鼠标模拟移动端滑动 v-scroll.x='bgc'
Vue.directive('scroll', {
  inserted (el, binding, vnode) {
    const { modifiers, value } = binding
    new Scroll({
      el,
      bar: { x: modifiers.xbar, y: modifiers.ybar, bgc: value },
      direction: modifiers.x ? 'x' : modifiers.y ? 'y' : 'xy',
    }).init()
  },
})

/* eslint-disable no-new */
window.$VM = new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
